define(['jquery', 'bootstrap', 'form', 'template'], function ($, Bootstrap, Form, Template) {
    var validatoroptions = {
        invalid: function (form, errors) {
            $.each(errors, function (i, j) {
                Layer.msg(j);
            });
        }
    };

    var Controller = {
        index:function () {
            $(window).on("scroll", function () {
                $("#mainNav").toggleClass("affix", $(window).height() - $(window).scrollTop() <= 50);
            });

            $(".domaincheck").on("click",function () {
                Layer.load();
                Fast.api.ajax({
                    url: check_url,
                    data: {domain:$("#domain").val(),'__token__':token},
                }, function (data, ret) {
                    Layer.closeAll('loading');
                    token = data.token;
                },function (data) {
                    Layer.closeAll('loading');
                    token = data.token;
                });
            });
            //百度统计
            // var _hmt = _hmt || [];
            // (function() {
            //     var hm = document.createElement("script");
            //     hm.src = "https://hm.baidu.com/hm.js?f108204acc200e475b43e4086f0b8b7e";
            //     var s = document.getElementsByTagName("script")[0];
            //     s.parentNode.insertBefore(hm, s);
            // })();

        },
        show:function () {

            window.addEventListener("message", function(e) {
                var data = e.data
                if(typeof data == "string"){
                    data = JSON.parse(data)
                }
                if(data.state=="1"){//显示二维码
                    layer.open({
                        content: "<img src='"+data.url+"' style='max-width:80%'; />"
                    });
                }else{//隐藏二维码
                    //that.showMa = false
                }
            }, false);


            $(window).ready(function(){
                var ua = navigator.userAgent.toLowerCase();
                //设置高度
                //$("#contentFrame").height($(window).height());
                $("#contentFrame").css("min-height",$(window).height());
                //设置宽度
                $("#contentFrame").width($(window).width());
                //显示
                $("#contentFrame").show();

                $("#contentFrame").removeAttr("scrolling");

                if(/iphone|ipad|ipod/.test(ua)){
                    var screenwidth = window.screen.width;
                    $("iframe").attr("scrolling","no");
                    $("#contentFrame").width(screenwidth);
                }
            });
        }
    };

    return Controller;
});